package com.spring.util;

/**
 * Copyright (c) 2018-2023 ThunderSoft
 * All Rights Reserved by Thunder Software Technology Co., Ltd and its affiliates.
 * You may not use, copy, distribute, modify, transmit in any form this file
 * except in compliance with ThunderSoft in writing by applicable law.
 */

import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;

/**
 * @author liyuncong
 * @version 1.0
 * @file ReflectionUtils
 * @brief ReflectionUtils
 * @details ReflectionUtils
 * @date 2023-02-22
 *
 * Edit History
 * ----------------------------------------------------------------------------
 * DATE                        NAME               DESCRIPTION
 * 2023-02-22                  liyuncong          Created
 */
public abstract class ReflectionUtils {

    @SuppressWarnings("deprecation")
    public static void makeAccessible(Constructor<?> constructor) {
        if ((!Modifier.isPublic(constructor.getModifiers())
            || !Modifier.isPublic(constructor.getDeclaringClass().getModifiers()))
            && !constructor.isAccessible()) {
            constructor.setAccessible(true);
        }
    }
}
